-
Notifications
You must be signed in to change notification settings - Fork 557
Add wasm32 support to the rust sdk #2704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@thlsrms Thank you for opening this! What's the current status? Are there parts still in progress, or should we be getting a reviewer on this? |
I've been working on support for the To keep this PR focused, I'll defer the emscripten support to a separate PR if necessary. I'll make some minor adjustments and rebase onto master. I'll ping you tomorrow if that's alright. |
@thlsrms absolutely, thank you! and no rush. I'm going to be out of office Wed-Fri this week, but either way it might take a little while for us to get around to reviewing, since we have some other things in progress right now. |
- `DbConnectionBuilder::build` becomes async without tokio's block_in_place. Still need to add `web` feature flag.
Replaces the unmaintained `anymap` dependency to fix a panic caused by `copy_nonoverlapping::precondition_check` due to alignment in `<TypeIdHasher as Hasher>::write` specific to web (wasm32) debug builds. The updated `anymap` fork drops its custom `Any` in favor of the standard library's `std::any::Any`.
Renamed the `run_threaded` method on `wasm32` to better reflect its behavior of spawning a background task. The generated `DbConnection` methods `run_threaded`, `run_background`, and `advance_one_message_blocking` now include runtime panics with a clear error feedback when called on unsupported targets.
Trim down repetitive `cfg` clauses by extracting common lock patterns into `get_lock_[sync|async]`.
@bfops When you're available, feel free to assign a reviewer. 👍 |
Description of Changes
Enabled the Rust SDK
wasm32
compilation target for web usage.wasm32-unknown-unknown
must set:RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
to enable getrandom's webassembly support.web
feature flag, incompatible with non-wasm32
targets.API and ABI breaking changes
None. Most changes apply only to the
wasm32
target, so there are no global breaking changes. The main differences to the native targets are:DBConnectionBuilder::build
is nowasync
on the web.File
struct unavailable on the web.gloo_storage
for local/session storage.HttpOnly
cookies).Expected complexity level and risk
Estimated at 2:
Opening this PR as a draft to get comments on it.
Testing
I built 2 demos to exercise the changes: